package csc.daonjpa.java.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import csc.daonjpa.java.domain.Transactions;
import csc.daonjpa.java.transaction.TransactionManager;

public class TransactionDAO {
	
	public boolean addTransaction(Transactions transaction) {
		EntityManager em = TransactionManager.getEntityManager();
		em.persist(transaction);
		return true;
	}
	
	public List<Transactions> getTransactions() {
		EntityManager em = TransactionManager.getEntityManager();
		TypedQuery<Transactions> query = em.createQuery("SELECT a FROM Transactions a", Transactions.class);
		List<Transactions> transactions = null;
		transactions = query.getResultList();
		return transactions;
	}

}
